

class CernaError(Exception):
    def __init__(self, mess):
        Exception.__init__()
        self.mess = mess

    def __str__(self):
        def errors(col):
            return {
                'set': '不是set',
                'list': '不是list',
                'num': '小于0',
            }[col]
        return repr(errors(self.mess))


class CeRNAPairs:
    def __init__(self, mirna, rna):
        self.set_mirna(mirna)
        self.set_rna(rna)

    def __and__(self, other):
        tem = self.mirna.intersection(other.mirna)
        if len(tem) > 0:
            return len(tem)
        else:
            return False
    def __eq__(self, other):
        if self.get_rna() == other.get_rna() and self.get_mirna() == self.get_mirna():
            return True
        else:
            return False

    def set_mirna(self, mirna):
        if isinstance(mirna, set):
            self.mirna = mirna
        else:
            raise CernaError('set')

    def set_rna(self, rna):
        self.rna = rna

    def get_mirna(self):
        return self.mirna

    def get_rna(self):
        return self.rna

    def get_num(self):
        return len(self.mirna)
